-- XianxiaStory.lua - 修仙游戏主入口文件
-- 整合所有修仙故事模块

-- 故事节点集合
local all_nodes = {}

-- 开场故事节点
local intro_nodes = {
    -- 游戏开始节点
    {
        id = "intro",
        title = "修仙之路",
        text = [[你是一名普通的山村少年，名叫叶辰。
在一个雷雨交加的夜晚，你偶然发现了一本古老的修仙秘籍。
这本秘籍将改变你的一生...]],
        vars = {
            ["player.name"] = "叶辰",
            ["player.health"] = 100,
            ["player.cultivation"] = "凡人",
            ["player.qi"] = 0,
            ["player.gold"] = 10,
            ["game.stage"] = "beginner"
        },
        choices = {
            {
                text = "立即开始修炼",
                next = "start_cultivation"
            },
            {
                text = "先了解一下秘籍内容",
                next = "study_manual"
            },
            {
                text = "将秘籍藏起来，明天再看",
                next = "hide_manual"
            }
        }
    },
    
    -- 开始修炼节点
    {
        id = "start_cultivation",
        title = "初次修炼",
        text = [[你按照秘籍上的方法开始修炼，感受到一股暖流在体内流动。
虽然过程有些艰难，但你坚持了下来。]],
        vars = {
            ["player.qi"] = 10,
            ["player.cultivation"] = "练气一层",
            ["game.score"] = 10
        },
        choices = {
            {
                text = "继续修炼",
                next = "study_breakthrough"
            },
            {
                text = "出门看看",
                next = "village_outside"
            },
            {
                text = "去村里的药铺",
                next = "village_apothecary"
            }
        }
    },
    
    -- 研究秘籍节点
    {
        id = "study_manual",
        title = "研读秘籍",
        text = [[你仔细研读了这本名为《基础炼气诀》的秘籍。
它详细介绍了修仙的基础知识和练气期的修炼方法。
你对修仙有了初步的了解。]],
        vars = {
            ["player.understanding"] = "basic",
            ["game.score"] = 5
        },
        choices = {
            {
                text = "开始修炼",
                next = "start_cultivation"
            },
            {
                text = "去请教村里的老猎人",
                next = "village_apothecary"
            }
        }
    },
    
    -- 隐藏秘籍节点
    {
        id = "hide_manual",
        title = "谨慎行事",
        text = [[你决定将秘籍藏在床底下的暗格里。
第二天清晨，你被一阵敲门声惊醒。
村长带着几名村民站在你家门口。]],
        vars = {
            ["game.morning"] = true,
            ["game.score"] = 2
        },
        choices = {
            {
                text = "开门询问",
                next = "village_visit"
            },
            {
                text = "假装不在家",
                next = "pretend_absent"
            }
        }
    },
    
    -- 村庄外部节点
    {
        id = "village_outside",
        title = "村庄外",
        text = [[你走出家门，呼吸着新鲜的空气。
村庄外的山林中传来鸟鸣声。
你看到几名村民在田间劳作。]],
        vars = {
            ["game.location"] = "village_outside"
        },
        choices = {
            {
                text = "去山林中看看",
                next = "mountain_forest"
            },
            {
                text = "和村民交谈",
                next = "talk_to_villagers"
            },
            {
                text = "返回家中",
                next = "intro"
            }
        }
    },
    
    -- 村里的药铺节点
    {
        id = "village_apothecary",
        title = "百草堂",
        text = [[你来到了村里唯一的药铺——百草堂。
药铺老板王伯是个慈祥的老人，他正在整理草药。
看到你进来，他热情地打招呼。]],
        vars = {
            ["game.location"] = "apothecary"
        },
        choices = {
            {
                text = "购买一些草药",
                next = "buy_herbs"
            },
            {
                text = "询问关于修仙的事情",
                next = "ask_about_cultivation"
            },
            {
                text = "离开药铺",
                next = "village_outside"
            }
        }
    }
}

-- 修炼相关故事节点
local cultivation_nodes = {
    -- 继续修炼节点
    {
        id = "continue_cultivation",
        title = "勤奋修炼",
        text = function(state)
            local cultivation = state.variables["player.cultivation"]
            return string.format("你沉浸在修炼中，不知不觉过去了三天。\n你的修为已经达到了%s，体内的灵气更加充沛。", cultivation)
        end,
        vars = {
            ["player.qi"] = function(state)
                return (state.variables["player.qi"] or 0) + 20
            end,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 15
            end
        },
        choices = {
            {
                text = "尝试突破到下一层",
                next = "attempt_breakthrough"
            },
            {
                text = "出门历练",
                next = "village_outside"
            },
            {
                text = "去寻找更好的修炼地点",
                next = "find_cultivation_spot"
            }
        }
    },
    
    -- 突破境界节点
    {
        id = "attempt_breakthrough",
        title = "突破境界",
        text = function(state)
            local qi = state.variables["player.qi"] or 0
            if qi >= 30 then
                return [[你感受到体内的灵气已经达到了瓶颈。
经过一番努力，你成功突破到了练气二层！]]
            else
                return [[你尝试突破，但体内的灵气不足。
突破失败了，你感到有些疲惫。]]
            end
        end,
        vars = function(state)
            local qi = state.variables["player.qi"] or 0
            if qi >= 30 then
                return {
                    ["player.cultivation"] = "练气二层",
                    ["player.qi"] = qi - 30,
                    ["game.score"] = (state.variables["game.score"] or 0) + 30
                }
            else
                return {
                    ["player.health"] = function(state)
                        return math.max(1, (state.variables["player.health"] or 100) - 10)
                    end,
                    ["game.score"] = (state.variables["game.score"] or 0) + 5
                }
            end
        end,
        choices = {
            {
                text = "继续修炼",
                next = "study_breakthrough"
            },
            {
                text = "出门庆祝",
                next = "village_outside"
            },
            {
                text = "研究突破的经验",
                next = "study_breakthrough"
            }
        }
    },
    
    -- 寻找修炼地点节点
    {
        id = "find_cultivation_spot",
        title = "寻找修炼圣地",
        text = [[你在山林中寻找适合修炼的地方。
经过一番探索，你发现了一个灵气浓郁的山洞。
山洞深处传来微弱的光芒。]],
        vars = {
            ["game.location"] = "mysterious_cave",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "进入山洞",
                next = "enter_cave"
            },
            {
                text = "在洞口修炼",
                next = "continue_cultivation"
            },
            {
                text = "返回村庄",
                next = "village_outside"
            }
        }
    },
    
    -- 进入山洞节点
    {
        id = "enter_cave",
        title = "神秘山洞",
        text = [[你进入了山洞，发现里面有一个古老的祭坛。
祭坛上放着一颗发光的珠子，散发着强大的灵气。]],
        vars = {
            ["game.discovery"] = "spirit_orb",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 20
            end
        },
        choices = {
            {
                text = "触摸发光的珠子",
                next = "touch_spirit_orb"
            },
            {
                text = "仔细观察祭坛",
                next = "touch_spirit_orb"
            },
            {
                text = "离开山洞",
                next = "find_cultivation_spot"
            },
            {
                text = "尝试吸收灵珠全部力量",
                next = "tragic_ending"
            }
        }
    },
    
    -- 触摸灵珠节点
    {
        id = "touch_spirit_orb",
        title = "灵珠的力量",
        text = [[你触摸了那颗发光的珠子，一股强大的灵气涌入你的体内。
你感到自己的修为在飞速提升！]],
        vars = {
            ["player.qi"] = function(state)
                return (state.variables["player.qi"] or 0) + 50
            end,
            ["player.cultivation"] = "练气三层",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 50
            end
        },
        choices = {
            {
                text = "继续探索山洞",
                next = "village_outside"
            },
            {
                text = "带着灵珠离开",
                next = "village_outside"
            },
            {
                text = "在山洞中修炼",
                next = "continue_cultivation"
            },
            {
                text = "尝试完全掌握灵珠力量",
                next = "become_grandmaster"
            }
        }
    },
    
    -- 研究突破经验节点
    {
        id = "study_breakthrough",
        title = "总结经验",
        text = [[你总结了这次突破的经验，对修炼有了更深的理解。
你觉得下次突破会更加顺利。]],
        vars = {
            ["player.understanding"] = "advanced",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "继续修炼",
                next = "continue_cultivation"
            },
            {
                text = "去村里的书店",
                next = "village_bookstore"
            }
        }
    }
}

-- 世界探索相关故事节点
local world_nodes = {
    -- 村长来访节点
    {
        id = "village_visit",
        title = "村长来访",
        text = [[村长告诉你，最近村里经常有野兽出没，希望你能帮忙解决。
作为村里唯一的修仙者，你义不容辞。]],
        vars = {
            ["game.quest"] = "kill_beasts",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "答应村长的请求",
                next = "accept_quest"
            },
            {
                text = "委婉拒绝",
                next = "refuse_quest"
            },
            {
                text = "询问更多详情",
                next = "ask_quest_details"
            }
        }
    },
    
    -- 假装不在家节点
    {
        id = "pretend_absent",
        title = "逃避现实",
        text = [[你假装不在家，村长和村民们离开了。
你知道这样做不对，但你还没有准备好面对他们。]],
        vars = {
            ["game.coward"] = true,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) - 10
            end
        },
        choices = {
            {
                text = "出去找村长道歉",
                next = "village_visit"
            },
            {
                text = "继续隐藏",
                next = "start_cultivation"
            }
        }
    },
    
    -- 山林探索节点
    {
        id = "mountain_forest",
        title = "山林深处",
        text = [[你进入了山林深处，这里的树木更加茂密。
你听到了一些奇怪的声音，可能是野兽的叫声。]],
        vars = {
            ["game.location"] = "mountain_forest",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "追踪声音来源",
                next = "track_sound"
            },
            {
                text = "寻找草药",
                next = "find_herbs"
            },
            {
                text = "返回村庄",
                next = "village_apothecary"
            }
        }
    },
    
    -- 与村民交谈节点
    {
        id = "talk_to_villagers",
        title = "村民的担忧",
        text = [[你和村民们交谈，他们告诉你最近村里确实不太平。
有村民在山上看到了体型巨大的野兽，还有人失踪了。]],
        vars = {
            ["game.quest_info"] = "beast_info",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "去山上调查",
                next = "mountain_forest"
            },
            {
                text = "去村长家",
                next = "village_visit"
            },
            {
                text = "回家修炼",
                next = "start_cultivation"
            }
        }
    },
    
    -- 药铺购买节点
    {
        id = "buy_herbs",
        title = "购买草药",
        text = [[王伯向你推荐了几种适合练气期修士使用的草药。
'这些草药可以帮助你恢复灵气，提升修炼速度。']],
        vars = {
            ["game.location"] = "apothecary",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 3
            end
        },
        choices = {
            {
                text = "购买补气丹（5金币）",
                next = "buy_qi_pill"
            },
            {
                text = "购买疗伤药（3金币）",
                next = "buy_qi_pill"
            },
            {
                text = "不买了，谢谢",
                next = "buy_qi_pill"
            }
        }
    },
    
    -- 询问修仙相关节点
    {
        id = "ask_about_cultivation",
        title = "关于修仙",
        text = [[王伯告诉你，他年轻的时候也见过修仙者。
'修仙之路充满艰辛，但也有着无限可能。'
他还提到附近有一个修仙门派，叫做青玄宗。]],
        vars = {
            ["game.sect_info"] = "qingxuan",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "询问青玄宗的位置",
                next = "go_to_qingxuan"
            },
            {
                text = "购买一些草药",
                next = "buy_herbs"
            },
            {
                text = "离开药铺",
                next = "village_outside"
            }
        }
    },
    
    -- 村里的书店节点
    {
        id = "village_bookstore",
        title = "古老书店",
        text = [[你发现村里有一家不起眼的书店。
书店老板是一位慈祥的老人，他告诉你这里有一些关于修仙的书籍。]],
        vars = {
            ["game.location"] = "bookstore",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "购买《修仙入门》（8金币）",
                next = "study_breakthrough"
            },
            {
                text = "询问有没有更高级的书籍",
                next = "study_breakthrough"
            },
            {
                text = "离开书店",
                next = "village_outside"
            }
        }
    }
}

-- 冲突和战斗相关故事节点
local conflict_nodes = {
    -- 接受任务节点
    {
        id = "accept_quest",
        title = "接受任务",
        text = [[村长对你的决定表示感谢，并给了你一些补给。
'小心点，那些野兽很凶猛。']],
        vars = {
            ["player.gold"] = function(state)
                return (state.variables["player.gold"] or 0) + 20
            end,
            ["game.quest_accepted"] = true,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 15
            end
        },
        choices = {
            {
                text = "立即前往山林",
                next = "mountain_forest"
            },
            {
                text = "先准备一下",
                next = "village_apothecary"
            }
        }
    },
    
    -- 拒绝任务节点
    {
        id = "refuse_quest",
        title = "拒绝任务",
        text = [[村长有些失望，但还是理解了你的决定。
'希望你能改变主意，村里真的需要帮助。']],
        vars = {
            ["game.quest_refused"] = true,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) - 5
            end
        },
        choices = {
            {
                text = "改变主意，接受任务",
                next = "accept_quest"
            },
            {
                text = "回家修炼",
                next = "start_cultivation"
            }
        }
    },
    
    -- 询问任务详情节点
    {
        id = "ask_quest_details",
        title = "任务详情",
        text = [[村长告诉你，野兽主要在山林的西边活动。
它们体型巨大，力大无穷，已经伤了好几个村民。
你需要杀死至少三只野兽才能解决问题。]],
        vars = {
            ["game.quest_details"] = "beast_details",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "接受任务",
                next = "accept_quest"
            },
            {
                text = "拒绝任务",
                next = "refuse_quest"
            }
        }
    },
    
    -- 追踪声音来源节点
    {
        id = "track_sound",
        title = "追踪野兽",
        text = [[你顺着声音追踪，发现了三只巨大的野猪。
它们正在破坏一片竹林，看起来非常愤怒。]],
        vars = {
            ["game.enemy"] = "giant_boars",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "主动攻击",
                next = "fight_boars"
            },
            {
                text = "悄悄观察",
                next = "fight_boars"
            },
            {
                text = "返回村庄报告",
                next = "village_outside"
            }
        }
    },
    
    -- 与野猪战斗节点
    {
        id = "fight_boars",
        title = "野猪之战",
        text = function(state)
            local cultivation = state.variables["player.cultivation"]
            if cultivation == "练气一层" then
                return [[你与野猪展开了激烈的战斗。
虽然你修为不高，但凭借着修仙者的优势，你勉强击败了一只野猪。
但剩下的两只野猪让你感到力不从心。]]
            elseif cultivation == "练气二层" then
                return [[你与野猪展开了激烈的战斗。
凭借着练气二层的修为，你成功击败了两只野猪。
第三只野猪见势不妙，逃跑了。]]
            else
                return [[你与野猪展开了战斗。
凭借着强大的修为，你轻松击败了所有三只野猪。
战斗结束后，你感到有些疲惫，但收获满满。]]
            end
        end,
        vars = function(state)
            local cultivation = state.variables["player.cultivation"]
            local result = {
                ["player.health"] = function(state)
                    return math.max(1, (state.variables["player.health"] or 100) - 20)
                end
            }
            
            if cultivation == "练气一层" then
                result["game.boars_killed"] = 1
                result["game.score"] = function(state)
                    return (state.variables["game.score"] or 0) + 20
                end
            elseif cultivation == "练气二层" then
                result["game.boars_killed"] = 2
                result["game.score"] = function(state)
                    return (state.variables["game.score"] or 0) + 35
                end
            else
                result["game.boars_killed"] = 3
                result["game.quest_completed"] = true
                result["game.score"] = function(state)
                    return (state.variables["game.score"] or 0) + 50
                end
            end
            
            return result
        end,
        choices = {
            {
                text = "回去交任务",
                next = "return_to_village"
            },
            {
                text = "继续寻找野兽",
                next = "track_sound"
            },
            {
                text = "挑战更强大的敌人",
                next = "tragic_ending"
            }
        }
    },
    
    -- 寻找草药节点
    {
        id = "find_herbs",
        title = "发现草药",
        text = [[你在山林中找到了一些珍贵的草药。
这些草药可以用来炼制丹药，提升修为。]],
        vars = {
            ["player.herbs"] = function(state)
                return (state.variables["player.herbs"] or 0) + 5
            end,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {
            {
                text = "继续寻找草药",
                next = "find_herbs"
            },
            {
                text = "返回村庄",
                next = "village_outside"
            },
            {
                text = "尝试炼制丹药",
                next = "buy_qi_pill"
            }
        }
    },
    
    -- 购买补气丹节点
    {
        id = "buy_qi_pill",
        title = "购买补气丹",
        text = [[你购买了一颗补气丹，服下后感到体内灵气增加了不少。
王伯告诉你，这是最适合练气期修士的丹药。]],
        vars = {
            ["player.gold"] = function(state)
                return math.max(0, (state.variables["player.gold"] or 0) - 5)
            end,
            ["player.qi"] = function(state)
                return (state.variables["player.qi"] or 0) + 15
            end,
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 5
            end
        },
        choices = {
            {
                text = "继续购买",
                next = "village_outside"
            },
            {
                text = "离开药铺",
                next = "village_outside"
            }
        }
    }
}

-- 结局相关故事节点
local ending_nodes = {
    -- 返回村庄节点
    {
        id = "return_to_village",
        title = "返回村庄",
        text = function(state)
            local quest_completed = state.variables["game.quest_completed"]
            local boars_killed = state.variables["game.boars_killed"] or 0
            
            if quest_completed then
                return [[你成功完成了任务，村长和村民们都对你表示感谢。
'你是我们村的英雄！'
村里为你举办了一场盛大的庆祝宴会。]]
            elseif boars_killed > 0 then
                return string.format([[你返回了村庄，告诉村长你杀死了%d只野猪。
村长对你的努力表示肯定，但希望你能继续完成任务。]], boars_killed)
            else
                return [[你空手而归，村长对你有些失望。
'希望你能再试一次，村里真的需要帮助。']]
            end
        end,
        vars = function(state)
            local quest_completed = state.variables["game.quest_completed"]
            if quest_completed then
                return {
                    ["player.gold"] = function(state)
                        return (state.variables["player.gold"] or 0) + 50
                    end,
                    ["game.village_hero"] = true,
                    ["game.score"] = function(state)
                        return (state.variables["game.score"] or 0) + 30
                    end
                }
            end
            return {}
        end,
        choices = {
            {
                text = "继续修炼",
                next = "continue_cultivation"
            },
            {
                text = "前往青玄宗",
                next = "go_to_qingxuan"
            },
            {
                text = "留在村里守护大家",
                next = "stay_in_village"
            },
            {
                text = "选择平凡的生活",
                next = "ordinary_ending"
            }
        }
    },
    
    -- 前往青玄宗节点
    {
        id = "go_to_qingxuan",
        title = "前往青玄宗",
        text = [[你决定前往青玄宗，寻求更高的修仙之道。
经过几天的跋涉，你终于来到了青玄宗的山脚下。
山门上写着四个大字：'青玄圣地'。]],
        vars = {
            ["game.location"] = "qingxuan_mountain",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 20
            end
        },
        choices = {
            {
                text = "上山拜师",
                next = "apply_to_sect"
            },
            {
                text = "在山脚下修炼",
                next = "continue_cultivation"
            },
            {
                text = "返回村庄",
                next = "village_outside"
            },
            {
                text = "放弃修仙",
                next = "ordinary_ending"
            }
        }
    },
    
    -- 留在村庄节点
    {
        id = "stay_in_village",
        title = "守护村庄",
        text = [[你决定留在村里，守护着村民们。
在你的保护下，村庄变得更加繁荣。
你成为了村里的守护者，受到所有人的尊敬。]],
        vars = {
            ["game.ending"] = "village_guardian",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 40
            end
        },
        choices = {}
    },
    
    -- 加入门派节点
    {
        id = "apply_to_sect",
        title = "加入青玄宗",
        text = function(state)
            local cultivation = state.variables["player.cultivation"]
            local score = state.variables["game.score"] or 0
            
            if cultivation == "凡人" then
                return [[你尝试加入青玄宗，但因为没有修为而被拒绝了。
'回去修炼几年再来吧。']]
            elseif cultivation == "练气一层" or cultivation == "练气二层" then
                return [[你通过了青玄宗的入门测试，成为了一名外门弟子。
'好好修炼，将来有机会成为内门弟子。']]
            elseif score >= 150 then
                return [[你凭借着强大的修为和出色的表现，直接被青玄宗的长老收为亲传弟子。
'你很有天赋，将来必成大器。']]
            else
                return [[你通过了青玄宗的测试，成为了一名内门弟子。
'继续努力，宗门的未来就靠你们了。']]
            end
        end,
        vars = function(state)
            local cultivation = state.variables["player.cultivation"]
            local score = state.variables["game.score"] or 0
            local result = {
                ["game.score"] = function(state)
                    return (state.variables["game.score"] or 0) + 30
                end
            }
            
            if cultivation == "凡人" then
                result["game.ending"] = "rejected_by_sect"
            elseif cultivation == "练气一层" or cultivation == "练气二层" then
                result["game.ending"] = "outer_disciple"
            elseif score >= 150 then
                result["game.ending"] = "personal_disciple"
            else
                result["game.ending"] = "inner_disciple"
            end
            
            return result
        end,
        choices = {}
    },
    
    -- 一代宗师结局
    {
        id = "become_grandmaster",
        title = "一代宗师",
        text = function(state)
            local name = state.variables["player.name"] or "叶辰"
            return string.format([[经过数十年的修炼，你成为了一代宗师。
你的名字%s响彻整个修仙界。
你开创了自己的门派，培养了无数优秀的弟子。
最终，你突破了凡人的极限，飞升成仙。]], name)
        end,
        vars = {
            ["game.ending"] = "grandmaster",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 100
            end
        },
        choices = {}
    },
    
    -- 平凡结局
    {
        id = "ordinary_ending",
        title = "平凡的一生",
        text = function(state)
            local name = state.variables["player.name"] or "叶辰"
            return string.format([[你选择了平凡的生活，在村里度过了一生。
虽然没有成为强大的修仙者，但你过得很幸福。
你的故事被村里的孩子们代代相传。]], name)
        end,
        vars = {
            ["game.ending"] = "ordinary",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 20
            end
        },
        choices = {}
    },
    
    -- 悲剧结局
    {
        id = "tragic_ending",
        title = "悲剧结局",
        text = [[你在一次冒险中遇到了强大的敌人，最终不敌。
你的修仙之路就此结束，但你的精神将永远激励着后人。
'修仙之路充满荆棘，只有真正的勇者才能走到最后。']],
        vars = {
            ["game.ending"] = "tragic",
            ["game.score"] = function(state)
                return (state.variables["game.score"] or 0) + 10
            end
        },
        choices = {}
    }
}

-- 合并所有故事节点
for _, node in ipairs(intro_nodes) do
    table.insert(all_nodes, node)
end

for _, node in ipairs(cultivation_nodes) do
    table.insert(all_nodes, node)
end

for _, node in ipairs(world_nodes) do
    table.insert(all_nodes, node)
end

for _, node in ipairs(conflict_nodes) do
    table.insert(all_nodes, node)
end

for _, node in ipairs(ending_nodes) do
    table.insert(all_nodes, node)
end

return all_nodes